package com.nuo.backend.config;

import com.nuo.backend.modules.test.interceptor.RequestBodyInterceptor;
import com.nuo.backend.modules.test.interceptor.SessionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* @description: TODO 配置拦截器
* @author nuo
* @date 2022/11/21 13:26
* @version 1.0
*/
@Component
public class InterceptorConfig implements WebMvcConfigurer {

   @Autowired
   private SessionInterceptor sessionInterceptor;

    @Autowired
    private RequestBodyInterceptor requestBodyInterceptor;


   @Override
   public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(sessionInterceptor)
               .addPathPatterns("/test/**")
               .order(1);
       registry.addInterceptor(requestBodyInterceptor)
               .addPathPatterns("/test/requestBodyThreadLocal")
               .order(2);
       WebMvcConfigurer.super.addInterceptors(registry);
   }


}
